<?php
	require('../db/database.php');
	
	if (isset($_GET['ai']) && isset($_COOKIE['session_key'])) {
		$ai = $_GET['ai'];
		
		//Error Checking
		if ($ai != 0 && $ai != 1) {
			echo "Invalid AI parameter value";
			exit;
		}
		
		$result = db_query("UPDATE session SET ai_flag = $ai WHERE session_key =". $_COOKIE['session_key']);
		if ($result != false) {
			echo "ai flag set to $ai";
		}
	} else {
		echo "Wrong parameter: ai flag and session key cookie must be provided";
	}
	
	
?>